Skip to content

feat(appender-tracing): propagate span name to logs#3466

Open
SuperFluffy wants to merge 6 commits intoopen-telemetry:mainfrom
SuperFluffy:propagate-span-name
Open

feat(appender-tracing): propagate span name to logs#3466
SuperFluffy wants to merge 6 commits intoopen-telemetry:mainfrom
SuperFluffy:propagate-span-name

Conversation

@SuperFluffy
Copy link
Copy Markdown
Contributor

Changes

Propagates the tracing span name to OTEL logs.

Similar to the experimental span attributes, the span containing the event is valuable to identify where and what happened.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@SuperFluffy SuperFluffy requested a review from a team as a code owner April 21, 2026 15:06
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.2%. Comparing base (5a07ce1) to head (b125321).

Additional details and impacted files
@@          Coverage Diff           @@
##            main   #3466    +/-   ##
======================================
  Coverage   84.1%   84.2%            
======================================
  Files        126     126            
  Lines      26720   26841   +121     
======================================
+ Hits       22490   22611   +121     
  Misses      4230    4230            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread opentelemetry-appender-tracing/src/layer.rs Outdated
Comment thread opentelemetry-appender-tracing/src/layer.rs
Copy link
Copy Markdown
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree we need to provide a way to attach span name, but need to also avoid picking an attribute name ourselves. See
#3466 (comment)

/// (the default) disables it.
#[cfg(feature = "experimental_span_attributes")]
pub fn with_span_name(mut self, key: impl Into<Key>) -> Self {
self.span_name_key = Some(key.into());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note sure in how far this matters, but key here should be set once and be alive until the end of the program. Does it make sense to Box::leak::<'static> the key/string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given this is tracing related, and tracing only has &static` keys, lets also accept that here?

Copy link
Copy Markdown
Contributor Author

@SuperFluffy SuperFluffy May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given this is tracing related, and tracing only has &static keys, lets also accept that here?

Can you clarify? Do you mean we should only have

        pub fn with_span_name(mut self, key: &'static str) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. We can internally make a Key cheaply using the static str.

Copy link
Copy Markdown
Contributor Author

@SuperFluffy SuperFluffy May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It's using static string refs now. Figured you don't want to Box::leak any arguments to make them 'static.

@SuperFluffy
Copy link
Copy Markdown
Contributor Author

Agree we need to provide a way to attach span name, but need to also avoid picking an attribute name ourselves. See #3466 (comment)

Did the changes. I guess this leaves open the question what to do if span and attribute names clash - but I don't think this crate should handle. Last time I checked the tracing crate itself just uses the last value it finds for a given key, so this is consistent.

@SuperFluffy SuperFluffy requested a review from cijothomas May 4, 2026 16:13
@cijothomas
Copy link
Copy Markdown
Member

Agree we need to provide a way to attach span name, but need to also avoid picking an attribute name ourselves. See #3466 (comment)

Did the changes. I guess this leaves open the question what to do if span and attribute names clash - but I don't think this crate should handle. Last time I checked the tracing crate itself just uses the last value it finds for a given key, so this is consistent.

The clash is not handled by the OTel api/sdk, so it is left to users. (Something to be revisited, but definitely outside scope of this PR)

@SuperFluffy
Copy link
Copy Markdown
Contributor Author

Updated the PR and removed the feature flags since span attribute propagation was stabilized.

/// attribute key. Setting this enables the propagation; leaving it unset
/// (the default) disables it.
///
/// This does nothing if `Self::with_tracing_span_attributes` is not set.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interaction with TracingSpanAttributes is odd now.

Should we scrap with_span_name in favor of extending TracingSpanAttributes (kinda like OpenOptions)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuperFluffy This requires some discussion to make sure we do a holistic approach. Given we are doing a release today, I reverted and kept the attribute enrichment gated behind feature flag (#3505).

I'll proceed with the release today, and after that, will get back to this. (Sorry we'll miss span-name enrichment in this release, but we can do ad-hoc release of this crate soon, so we don't have to wait for next full release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants